<%@ page import="pro.wyn.pojo.Goods" %>
<%@ page import="pro.wyn.JdbcUtils" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>

<%
    String id = request.getParameter("i");
    Goods goods =null;
    if(id!=null){
        //当存在id的时候，查询数据库中的数据
        String sql="SELECT `name` ,price from goods where id=?";
        goods = JdbcUtils.select(sql, Goods.class, id);
    }else{
        //当不存在id，创建一个空的
        goods =new Goods();
        goods.setName("");
        goods.setPrice(0);
    }
%>
<html lang="zh">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Java实训团队协作简单案例 - 商品信息编辑页面</title>
    <link rel="shortcut icon" href="assets/img/favicon.ico" type="image/x-icon" />
    <link rel="stylesheet" href="assets/vendors/font-awesome-4.7.0/css/font-awesome.min.css" />
    <link rel="stylesheet" href="assets/css/core.css" />
    <link rel="stylesheet" href="assets/css/index.css" />

    <link rel="stylesheet" href="assets/css/goods.css" />
</head>

<body>
    <jsp:include page="/WEB-INF/tpl/wyn/header.jsp"/>

    <section class="container">
        <jsp:include page="/WEB-INF/tpl/wyn/left.jsp"/>
        <div class="main-right">
            <h3>商品信息编辑页面</h3>
            <form action="/wyngoods/save" method="post" enctype="multipart/form-data">
                名称：<input name="n" type="text" />
                单价：<input name="p" type="number"/>
                图片：<input name="i" type="file" />
                <button>保存</button>
            </form>
        </div>
    </section>
</body>

</html>